package com.tanhua.controller;

import com.tanhua.domain.mongo.Soul;
import com.tanhua.service.SoulService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @author user
 * TODO：试卷增删改查
 * 试卷
 */
@RestController
@RequestMapping("/soul")
@CrossOrigin
public class SoulController {

    @Autowired
    public SoulService soulService;

    /**
     * 查询试卷列表
     */
    @GetMapping("/getsoullist")
    public ResponseEntity getSoulList() {
        return soulService.getSoulList();
    }

    /**
     * 删除试卷
     */
    @GetMapping("/deletesoulid")
    public ResponseEntity deleteSoulId(Integer soulId) {
        return soulService.deleteSoulId(soulId);
    }

    /**
     * 添加试卷
     */
    @PostMapping("/addsoul")
    public ResponseEntity addSoul(@RequestBody Soul soul) {
//      直接在试卷表中添加数据
        return soulService.addSoul(soul);
    }


    /**
     * 修改试卷
     */
    @PostMapping("/updatesoul")
    public ResponseEntity updateSoul(@RequestBody Soul soul) {
        return soulService.updateSoul(soul);

    }

    /**
     * 根据id查询单个试卷
     *
     * @param souid
     * @return
     */
    @GetMapping("/getSoulId/{souid}")
    public ResponseEntity getSoulId(@PathVariable("souid") String souid) {
        return soulService.getSoulId(souid);
    }
}
